﻿''' <summary>
''' Tracks the state of each button on the mouse as well as the mouse position.
''' </summary>
''' <remarks></remarks>
Public Structure MouseStateInfo
    Private None As Boolean
    Private Left As Boolean
    Private Right As Boolean
    Private Middle As Boolean
    Private XButton1 As Boolean
    Private XButton2 As Boolean

    ''' <summary>
    ''' Gets the value of pressed-state for the specified MouseButton.
    ''' </summary>
    ''' <param name="button">The MouseButton whose state should be returned.</param>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Default Public ReadOnly Property Item(ByVal button As MouseButtons) As Boolean
        Get
            Dim field As System.Reflection.FieldInfo
            field = Me.GetType.GetField([Enum].GetName(GetType(MouseButtons), button), Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
            Return CBool(field.GetValue(Me))
        End Get
    End Property

    Private _MouseLocation As Point
    ''' <summary>
    ''' Returns the current mouse pointer location.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property MouseLocation As Point
        Get
            Return _MouseLocation
        End Get
    End Property

    ''' <summary>
    ''' Sets the pressed-state for the specified MouseButton.
    ''' </summary>
    ''' <param name="button">The MouseButton whose state should be set.</param>
    ''' <param name="value">The pressed-state of the specified MouseButton.</param>
    ''' <remarks></remarks>
    Friend Sub SetButton(ByVal button As MouseButtons, ByVal value As Boolean)
        Select Case button
            Case MouseButtons.None
                None = value
            Case MouseButtons.Left
                Left = value
            Case MouseButtons.Right
                Right = value
            Case MouseButtons.Middle
                Middle = value
            Case MouseButtons.XButton1
                XButton1 = value
            Case MouseButtons.XButton2
                XButton2 = value
        End Select
    End Sub

    ''' <summary>
    ''' Sets the current mouse pointer location.
    ''' </summary>
    ''' <param name="toValue"></param>
    ''' <remarks></remarks>
    Friend Sub SetLocation(ByVal toValue As Point)
        _MouseLocation = toValue
    End Sub
End Structure